nm options filename1 [filename2...filenamen]
Table 2-9 defines the one-character codes shown in an nm listing. Refer to the example that follows the table for a sample listing.
#include <stdio.h> #include <math.h> #define LIMIT 12 int unused_item = 14; double mydata[LIMIT]; main() { int i; for(i = 0; i < LIMIT; i++) { mydata[i] = sqrt((double)i); } return 0; }Compile the program into an object file by entering:
To obtain symbol table information for the object file tnm.o in BSD format, use the nm -B command:cc -c tnm.c
0000000000 T main 0000000000 B mydata 0000000000 U sqrt 0000000000 D unused_item 00000000 N _bufendtabTo obtain symbol table information for the object file tnm.o in SVR4 format, use the nm command without any options:
Symbols from tnm.o: [Index] Value Size Class Type Section Name [0] | 0| |File |ref=4 |Text | tnm.c [1] | 0| |Proc |end=3 int |Text | main [2] | 116| |End |ref=1 |Text | main [3] | 0| |End |ref=0 |Text | tnm.c [4] | 0| |File |ref=6 |Text | /usr/include/math.h [5] | 0| |End |ref=4 |Text | /usr/include/math.h [6] | 0| |Global | |Data | unused_item [7] | 0| |Global | |Bss | mydata [8] | 0| |Proc |ref=1 |Text | main [9] | 0| |Proc | |Undefined| sqrt [10] | 0| |Global | |Undefined| _gp_disp